//
//  PayForDbbVC.m
//  夺宝吧
//
//  Created by xiaocai on 15/6/29.
//  Copyright (c) 2015年 FangYuan. All rights reserved.
//

#import "PayForDbbVC.h"
#import "AFFNumericKeyboard.h"
#import "JDWebPayVC.h"
#import "PayedVC.h"


//update by weienjie 20150918
#import "Iapppay.h"
//end weienjie



@interface PayForDbbVC ()<UITextFieldDelegate,AFFNumericKeyboardDelegate>
{
    
    __weak IBOutlet UIButton *m_btn_1;
    __weak IBOutlet UIButton *m_btn_2;
    __weak IBOutlet UIButton *m_btn_3;
    __weak IBOutlet UIButton *m_btn_4;
    __weak IBOutlet UIButton *m_btn_5;
    __weak IBOutlet UITextField *inputText;
    __weak IBOutlet UIButton *commitBtn;
    __weak IBOutlet UILabel *moneyLab;
    __weak IBOutlet UILabel *jiFenLab;
    __weak IBOutlet UILabel *countLab;
    __weak IBOutlet UIImageView *headerImg;
    __weak IBOutlet UILabel *mmoneyLab;
    __weak IBOutlet UILabel *mjifenLab;
    __weak IBOutlet UIView *whiteV1;
    __weak IBOutlet UIView *whiteV2;
    __weak IBOutlet UIView *whiteV3;
    __weak IBOutlet UIButton *zfbBtn;
    __weak IBOutlet UIButton *jdBtn;
    __weak IBOutlet UIButton *tzfbBtn;
    __weak IBOutlet UIButton *tjdBtn;
    //update by weienjie 20150918
    __weak IBOutlet UIButton *wxzfBtn;
    __weak IBOutlet UIButton *twxzfBtn;
    // update end weienjie
    
    __weak IBOutlet UIImageView *zfbimg;
    __weak IBOutlet UIImageView *jdimg;
    
    __weak IBOutlet UILabel *getLab;
    __weak IBOutlet UILabel *smlab;
    __weak IBOutlet UILabel *smlab1;
    __weak IBOutlet UILabel *smlab2;
    __weak IBOutlet UILabel *smlab3;
    
    //update by weienjie 20150918
    __weak IBOutlet UIScrollView *scrollView;
    //end weienjie
    
    //放按钮的数组
    NSArray *m_btns;
    //记录积分换算比例
    NSArray *jifens;
    //记录支付方式
    NSString *_payWay;
    
    //记录订单信息
    NSString *_orderId;
    NSString *_orderNum;
    
    __weak IBOutlet UIImageView *wximg;

    __weak IBOutlet UILabel *zhbLabel;
    __weak IBOutlet UILabel *zhbdesLabel;
    __weak IBOutlet UILabel *jdLabel;
    __weak IBOutlet UILabel *jddesLabel;
    __weak IBOutlet UILabel *wxLabel;
    __weak IBOutlet UILabel *wxdesLabel;
    
    UILabel *zhegai;

}
@end

@implementation PayForDbbVC
- (void)awakeFromNib
{
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    headerImg.layer.masksToBounds = YES;
    headerImg.layer.borderWidth = 2;
    headerImg.frame = CGRectMake(headerImg.frame.origin.x, headerImg.frame.origin.y, headerImg.frame.size.width*AUTOY, headerImg.frame.size.height*AUTOY);
    headerImg.layer.borderColor = [[UIColor whiteColor] CGColor];
    headerImg.layer.cornerRadius = headerImg.frame.size.width/2;
    
    
    /*
    UIView *line1 = [WYPublic getFenGexian:0 :0 :WYMWITH :0.5];
    [whiteV1 addSubview:line1];
    
    UIView *line2 = [WYPublic getFenGexian:0 :(whiteV1.frame.size.height-0.5)*AUTOY :WYMWITH :0.5];
    [line2 setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin];
    [whiteV1 addSubview:line2];
    
    UIView *line3 = [WYPublic getFenGexian:0 :0 :WYMWITH :0.5];
    [line3 setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin];
    [whiteV2 addSubview:line3];
    //update by weienjie 20150918
    [whiteV2 addSubview:[WYPublic getFenGexian:0 :whiteV2.frame.size.height/3 *AUTOY:WYMWITH :0.5]];
    [whiteV2 addSubview:[WYPublic getFenGexian:0 :whiteV2.frame.size.height*2/3 *AUTOY:WYMWITH :0.5]];
    //update end weienjie
    
    UIView *line4 = [WYPublic getFenGexian:0 :(whiteV2.frame.size.height-0.5)*AUTOY :WYMWITH :0.5];
    [line4 setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin];
    [whiteV2 addSubview:line4];
    
//    [whiteV2 addSubview:[WYPublic getFenGexian:0 :(whiteV2.frame.size.height/2)*AUTOY :WYMWITH :0.5]];
    [whiteV3 addSubview:[WYPublic getFenGexian:0 :0 :WYMWITH :0.5]];
    [whiteV3 addSubview:[WYPublic getFenGexian:0 :(whiteV3.frame.size.height-0.5)*AUTOY :WYMWITH :0.5]];
//    [whiteV3 addSubview:[WYPublic getFenGexian:0 :(whiteV3.frame.size.height/2)*AUTOY :WYMWITH :0.5]];
     */
    [zfbBtn setImage:[UIImage imageNamed:@"icon_checkbox_press"] forState:UIControlStateSelected];
    zfbBtn.selected = YES;
    [jdBtn setImage:[UIImage imageNamed:@"icon_checkbox_press"] forState:UIControlStateSelected];
    
    //update by weienjie 20150918
    [wxzfBtn setImage:[UIImage imageNamed:@"icon_checkbox_press"] forState:UIControlStateSelected];
    //update end weienjie
    //界面处理
    [self reloadSubViews];
    //屏蔽键盘事件
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(closeKeyBoard:)];
    [self.view addGestureRecognizer:tap];
    //自定义键盘
    AFFNumericKeyboard *keyboard = [[AFFNumericKeyboard alloc] initWithFrame:CGRectMake(0, WYMHEIGHT-216, WYMWITH, 216)];
    inputText.inputView = keyboard;
    keyboard.delegate = self;
    
    //updat by weienjie 20150918
    [[IapppayKit sharedInstance] setAppId:mOrderUtilsAppId mACID:mOrderUtilsChannel];

    
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
//    [scrollView setContentSize:CGSizeMake(0, CGRectGetHeight(scrollView.frame)+60)];
}

//- (void)viewDidLayoutSubviews
//{
////    [scrollView setFrame:self.view.frame];
//    //update by weienjie 20150918
//    [super viewDidLayoutSubviews];
//    [scrollView setContentSize:CGSizeMake(0, CGRectGetHeight(scrollView.frame)+60)];
//    //end weienjie
//
//    NSLog(@"viewDidLayoutSubviews");
//}
- (void)setPeizhiDic:(NSDictionary *)peizhiDic
{
    _peizhiDic = peizhiDic;
    jifens = _peizhiDic[@"consume_score_config"];
}
//关闭键盘
- (void)closeKeyBoard:(UIGestureRecognizer *)ges
{
    CGPoint point = [ges locationInView:scrollView];
    NSLog(@"point = %@",NSStringFromCGPoint(point));
    if (point.y> CGRectGetHeight(self.view.frame))
    {
        [self commitBtnOnClick:nil];
    }
    [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
}
//界面处理
- (void)reloadSubViews
{
    m_btns = @[m_btn_1,m_btn_2,m_btn_3,m_btn_4,m_btn_5];
    //添加边框
    for (UIButton *btn in m_btns) {
        btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
        btn.layer.borderWidth = 0.5;
    }
    m_btn_1.layer.borderColor = QBB_RED_COLOR.CGColor;
    m_btn_1.selected = YES;
    commitBtn.layer.cornerRadius = 2;
    commitBtn.layer.masksToBounds = YES;
    inputText.layer.borderWidth = 0.5;
    inputText.layer.borderColor = [UIColor lightGrayColor].CGColor;
    inputText.delegate = self;
    moneyLab.attributedText = [WYPublic getRedMiddleStrWithLeft:@"夺币:" Middle:@"50" RightStr:@"" Font:13];
    jiFenLab.attributedText = [WYPublic getRedMiddleStrWithLeft:@"积分:" Middle:[NSString stringWithFormat:@"%ld",(unsigned long)[self getJiFen:[m_btn_1.titleLabel.text integerValue]]] RightStr:@"(活动期间充值所送，100积分=1夺宝币)" Font:13];
    
    UserInfo *user = [[UserInfo alloc]init];
    [headerImg sd_setImageWithURL:[NSURL URLWithString:user.user_header_img_path] placeholderImage:[UIImage imageNamed:@"icon_login_head"]];
    countLab.text = user.user_name;
    if (user.user_money != nil) {
            mmoneyLab.text = [NSString stringWithFormat:@"夺币:%@",user.user_money];
    }else{
        mmoneyLab.text = @"夺币:0";
    }
    if (user.user_jifen != nil) {
        mjifenLab.text = [NSString stringWithFormat:@"积分:%@",user.user_jifen];
    }else{
        mjifenLab.text = @"积分:0";
    }
    
    NSDictionary *payWays = _peizhiDic[@"valid_pays"];
    if (payWays.count > 0) {
        NSNumber *jd = nil;
        if ([payWays[@"pingpp"][@"available"] class] != [NSNull class]) {
            jd = payWays[@"pingpp"][@"available"];
        }
        NSNumber *zfb = nil;
        if ([payWays[@"alipay_mobile"][@"available"] class] != [NSNull class]) {
            zfb = payWays[@"alipay_mobile"][@"available"];
        }
        NSNumber *wxzf = nil;
        if ([payWays[@"alipay_mobile"][@"available"] class] != [NSNull class]) {
            wxzf = payWays[@"iapppay"][@"available"];
        }
        if (zfb.integerValue == 0) {
            [self changeZFB];
        }
        if (jd.integerValue == 0) {
            [self changeJD];
        }
        if (wxzf.integerValue == 0) {
            [self changeIAPPPay];
        }
    }
}
//调整支付宝坐标
- (void)changeZFB
{
    wxzfBtn.frame = jdBtn.frame;
    wximg.frame = jdimg.frame;
    twxzfBtn.frame = tjdBtn.frame;
    wxLabel.frame = jdLabel.frame;
    wxdesLabel.frame = jddesLabel.frame;
    
    jdBtn.frame = zfbBtn.frame;
    jdimg.frame = zfbimg.frame;
    tjdBtn.frame = tzfbBtn.frame;
    jdLabel.frame = zhbLabel.frame;
    jddesLabel.frame = zhbdesLabel.frame;
    
    
    
    zfbimg.hidden = YES;
    zfbBtn.hidden = YES;
    tzfbBtn.hidden = YES;
    zhbLabel.hidden = YES;
    zhbdesLabel.hidden = YES;
    [self ifNoAll];
}
//调整京东支付坐标
- (void)changeJD
{
    wxzfBtn.frame = jdBtn.frame;
    wximg.frame = jdimg.frame;
    twxzfBtn.frame = tjdBtn.frame;
    wxLabel.frame = jdLabel.frame;
    wxdesLabel.frame = jddesLabel.frame;
    
    jdimg.hidden =YES;
    jdBtn.hidden = YES;
    tjdBtn.hidden = YES;
    jddesLabel.hidden = YES;
    jdLabel.hidden = YES;
    
    //    UILabel *zhegai = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMinY(tjdBtn.frame)-3, WYMWITH, 120)];
    //    zhegai.backgroundColor = QBB_GRAY_COLOR;
    //    [whiteView addSubview:zhegai];
    [self ifNoAll];
}

//update by weienjie 20150918
//调整爱贝支付坐标
- (void)changeIAPPPay
{
    wximg.hidden =YES;
    wxzfBtn.hidden = YES;
    twxzfBtn.hidden = YES;
    wxdesLabel.hidden = YES;
    wxLabel.hidden = YES;
    
    //    UILabel *zhegai = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMinY(twxBtn.frame)-3, WYMWITH, 60)];
    //    zhegai.backgroundColor = QBB_GRAY_COLOR;
    //    [whiteView addSubview:zhegai];
    [self ifNoAll];
    
}
//如果都没有
- (void)ifNoAll
{    
    CGFloat height = 0;
    if (!zfbimg.hidden && !jdimg.hidden && !wximg.hidden) {
        height = 0;
    }
    else if (!zfbimg.hidden && !jdimg.hidden && !wximg.hidden)
    {
        height = CGRectGetHeight(whiteV2.frame);
    }
    else if ((zfbimg.hidden && !jdimg.hidden && !wximg.hidden) || (jdimg.hidden && !zfbimg.hidden && !wximg.hidden) || (wximg.hidden && !zfbimg.hidden && !jdimg.hidden))
    {
        height = CGRectGetHeight(whiteV2.frame)/3.0;
    }
    else{
        height = CGRectGetHeight(whiteV2.frame)*2/3.0;
    }
    if (!zhegai) {
        zhegai = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetHeight(whiteV2.frame)-height, WYMWITH, height)];
        zhegai.backgroundColor = QBB_GRAY_COLOR;
    }
    [zhegai setFrame:CGRectMake(0, whiteV2.frame.origin.y+CGRectGetHeight(whiteV2.frame)-height, WYMWITH, height)];
    [whiteV2 addSubview:zhegai];
}
//调整下方坐标
- (void)changeBottom:(CGFloat)height
{
//    whiteV3.center = CGPointMake(whiteV3.center.x, whiteV3.center.y - height);
//    moneyLab.center = CGPointMake(moneyLab.center.x, moneyLab.center.y - height);
//    jiFenLab.center = CGPointMake(jiFenLab.center.x, jiFenLab.center.y - height);
//    getLab.center = CGPointMake(getLab.center.x, getLab.center.y - height);
//    smlab.center = CGPointMake(smlab.center.x, smlab.center.y - height);
//    smlab1.center = CGPointMake(smlab1.center.x, smlab1.center.y - height);
//    smlab2.center = CGPointMake(smlab2.center.x, smlab2.center.y - height);
//    smlab3.center = CGPointMake(smlab3.center.x, smlab3.center.y - height);
}
//返回按钮的监听事件
- (IBAction)backBtnOnClick:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
//资金数额按钮的点击事件
- (IBAction)m_btnsOnClick:(id)sender {
    //改变边框颜色
    for (UIButton *btn in m_btns) {
        btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
        btn.selected = NO;
    }
    UIButton *bbtn = (UIButton *)sender;
    bbtn.selected = YES;
    bbtn.layer.borderColor = QBB_RED_COLOR.CGColor;
    [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
    inputText.layer.borderColor = [UIColor lightGrayColor].CGColor;
    moneyLab.attributedText = [WYPublic getRedMiddleStrWithLeft:@"夺币:" Middle:bbtn.titleLabel.text RightStr:@"" Font:14];
    jiFenLab.attributedText = [WYPublic getRedMiddleStrWithLeft:@"积分:" Middle:[NSString stringWithFormat:@"%ld",(unsigned long)[self getJiFen:[bbtn.titleLabel.text integerValue]]] RightStr:@"(活动期间充值所送，100积分=1夺宝币)" Font:14];
}
//换算积分
-(NSInteger)getJiFen:(NSInteger)money
{
    NSInteger rlt = 0;
    for (NSDictionary *jifen in jifens) {
        NSNumber *min = jifen[@"gte"];
        NSNumber *max = jifen[@"lte"];
        NSNumber *bili = jifen[@"percent"];
        if (money >= min.integerValue && money <= max.integerValue) {
            rlt = money*bili.floatValue;
        }
    }
    if (rlt <= 0) {
        //隐藏积分lab
        jiFenLab.hidden = YES;
    }else {
        jiFenLab.hidden = NO;

    }
    return rlt;
}
//提交按钮的监听事件
- (IBAction)commitBtnOnClick:(id)sender {
    float price = 0;
    BOOL btnFlag = NO;
    
    //取得支付的钱的数量
    for (UIButton *btn in m_btns) {
        if (btn.selected) {
            price = [[btn titleForState:UIControlStateNormal] floatValue];
            btnFlag = YES;
        }
        
    }
    if (btnFlag == NO) {
        price = [inputText.text floatValue];
        if ((price < 1) || price > 10000.0){
            [WYPublic showErrorWithTitle:nil Msg:@"充值金额必须为大于1小于10000的整数"];
            inputText.text= nil;
            return;
        }
    }
    //开始生成订单
    if (price > 0) {
        [WYPublic addZheZhaoToWindowWithTitle:nil];
        //先生成订单
        NSDictionary *pararms = @{@"money":[NSNumber numberWithFloat:price],@"uid":[UserInfo getUserID],@"token":[UserInfo getUserToken],@"refresh_token":[UserInfo getRefreshToken]};
        [WYRequest startPostForDicWithUrlStR:[NSString stringWithFormat:@"%@%@",DBB_IP,MAKEORDER_URL] Parameters:pararms successBlock:^(NSDictionary *dic) {
            NSNumber *ret = dic[@"ret"];
            if (ret.intValue == 0) {
                _orderId = dic[@"data"][@"pay_order"][@"id"];
                _orderNum = dic[@"data"][@"pay_order"][@"pay_code"];
                
                //支付宝支付 和 爱贝微信支付
                if (zfbBtn.selected || wxzfBtn.selected) {
                    //验证并支付
                    [self payYanzheng:price];
                }
                //京东支付
                else if (jdBtn.selected) {
                    JDWebPayVC *jdvc = [[JDWebPayVC alloc]init];
                    jdvc.mtitle = @"支付页面";
                    jdvc.isChongZhiFlag = YES;
                    jdvc.money = [NSString stringWithFormat:@"%0.2f",price];
                    jdvc.urlStr = [NSString stringWithFormat:@"%@api/ApiPay/pay?uid=%@&token=%@&id=%@&pay_type=pingpp&sub_pay_type=jdpay_wap",DBB_IP,[UserInfo getUserID],[UserInfo getUserToken],_orderId];
                    [[WYMainTabBarVC shareMainTaBarVC].navigationController pushViewController:jdvc animated:YES];
                }
        }else{
                [WYPublic showMessageWithTitle:@"提示：" Msg:@"订单生成失败"];
            }
            [WYPublic removeZheZhaoToWindow];
        } failedBlock:^{
            [WYPublic removeZheZhaoToWindow];
        } needLog:NO];

    }else{
        
        [WYPublic showMessageWithTitle:@"提示：" Msg:@"金额为0"];
    }
}
//支付前验证
- (void)payYanzheng:(float)price
{
    NSString *payStyle = @"alipay_mobile";
    if(jdBtn.selected){
        payStyle = @"pingpp";
    }
    else if(wxzfBtn.selected){
        payStyle = @"iapppay";
    }
    NSDictionary *params = @{@"id":_orderId,@"pay_type":payStyle,@"uid":[UserInfo getUserID],@"token":[UserInfo getUserToken],@"refresh_token":[UserInfo getRefreshToken]};
    [WYRequest startPostForDicWithUrlStR:[NSString stringWithFormat:@"%@%@",DBB_IP,YANZHENG_URL] Parameters:params successBlock:^(NSDictionary *dic) {
        NSNumber *ret = dic[@"ret"];
        if ([ret intValue] == 0) {
            if (zfbBtn.selected) {/***********支付宝支付*************/
                WYZfbPay *zfbPay = [[WYZfbPay alloc]init];
                //                    NSLog(@"---->id=%@,num=%@,price=%@",_orderId,_orderNum,[NSString stringWithFormat:@"%0.2f",price]);
                zfbPay.isChongZhiFlag = YES;
                [zfbPay zfbPayWithOrderNum:_orderNum OrderId:_orderId PdcTitle:@"夺宝吧充值_iOS" PdcDesc:[NSString stringWithFormat:@"夺宝吧支付_iOS_%@",_orderNum] Price:[NSString stringWithFormat:@"%0.2f",price]];
                //跳往支付结果界面
//                [self.navigationController popViewControllerAnimated:YES];
                PayedVC *payedVC = [[PayedVC alloc]init];
                payedVC.money = [NSString stringWithFormat:@"%0.2f",price];
                payedVC.isChongZhiFlag = YES;
                [[WYMainTabBarVC shareMainTaBarVC].navigationController pushViewController:payedVC animated:YES];
            }
            //update by weienie 20150918
            else if (wxzfBtn.selected) {//爱贝支付
                Iapppay *iappay = [[Iapppay alloc] init];
                iappay.isChongZhiFlag = YES;
                //接口阉割
//                [iappay iappayWithOrderId:_orderNum price:[NSString stringWithFormat:@"%0.2f",price] privateInfo:[NSString stringWithFormat:@"夺宝吧支付_iOS_%@",_orderNum]];
                
                //跳往支付结果界面
//                [self.navigationController popViewControllerAnimated:YES];
                PayedVC *payedVC = [[PayedVC alloc]init];
                payedVC.money = [NSString stringWithFormat:@"%0.2f",price];
                payedVC.isChongZhiFlag = YES;
                [[WYMainTabBarVC shareMainTaBarVC].navigationController pushViewController:payedVC animated:YES];
            }
            //update end weienjie

            else if(jdBtn.selected){/**********京东支付**************/
                
            }else{
                [WYPublic showMessageWithTitle:@"提示：" Msg:@"交易故障，请耐心等待……"];
            }

        }

    } failedBlock:^{
        
    } needLog:NO];
}

#pragma mark -- 自定义键盘代理
-(void)changeKeyboardType
{
    [inputText resignFirstResponder];
    inputText.inputView = nil;
    [inputText becomeFirstResponder];
}

-(void)numberKeyboardBackspace
{
    if (inputText.text.length != 0)
    {
        inputText.text = [inputText.text substringToIndex:inputText.text.length -1];
    }
}

-(void)numberKeyboardInput:(NSInteger)number
{
    inputText.text = [inputText.text stringByAppendingString:[NSString stringWithFormat:@"%ld",(unsigned long)number]];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [inputText resignFirstResponder];
}
//完成按钮
- (void) doneBtnOnClick
{
    [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
//    inputText.layer.borderColor = QBB_RED_COLOR.CGColor;
//    jiFenLab.attributedText = [WYPublic getRedMiddleStrWithLeft:@"积分:" Middle:[NSString stringWithFormat:@"%ld",(unsigned long)[self getJiFen:[inputText.text integerValue]]] RightStr:@"(活动期间充值所送，100积分=1夺宝币)" Font:14];
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    //改变边框颜色
    for (UIButton *btn in m_btns) {
        btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
        btn.selected = NO;
    }
    inputText.layer.borderColor = QBB_RED_COLOR.CGColor;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
    inputText.layer.borderColor = QBB_RED_COLOR.CGColor;
    moneyLab.attributedText = [WYPublic getRedMiddleStrWithLeft:@"夺币:" Middle:inputText.text RightStr:@"" Font:14];
    jiFenLab.attributedText = [WYPublic getRedMiddleStrWithLeft:@"积分:" Middle:[NSString stringWithFormat:@"%ld",(unsigned long)[self getJiFen:[inputText.text integerValue]]] RightStr:@"(活动期间充值所送，100积分=1夺宝币)" Font:14];
}

//提交按钮的监听事件
- (IBAction)commit:(id)sender {
    
}
//选项按钮的监听事件
- (IBAction)selectBtnOnCLick:(UIButton *)sender {
    //update by weienjie 20150918
    if (sender == tzfbBtn) {
        zfbBtn.selected = YES;
        jdBtn.selected = NO;
        wxzfBtn.selected = NO;
    }else if (sender == tjdBtn)
    {
        zfbBtn.selected = NO;
        wxzfBtn.selected = NO;
        jdBtn.selected = YES;
    }
    else if (sender == twxzfBtn){
        jdBtn.selected = NO;
        zfbBtn.selected = NO;
        wxzfBtn.selected = YES;
    }
    //update end
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
